package com.sondon.dev_info.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sondon.dev_info.entity.User;
import com.sondon.dev_info.service.UserManager;

/**
 * @Project : dplus_shop
 * @Package : com.sondon.dplus_shop.controller
 * @Class : UserController.java
 * @Company  ***广州讯动网络科技有限公司***
 * @Author : 蔡文锋
 * @DateTime：2015年4月1日 上午11:26:19
 * @Blog：http://blog.csdn.net/caiwenfeng_for_23
 * @Description : { }
 */
@Controller
public class UserController {
	@Autowired
	private UserManager userManager;

	@RequestMapping("/all_user")
	@ResponseBody
	public List<User> All_User(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {
		System.out.println("this  is UserController。。。。。。。");
		List<User> list = userManager.getAllUser();
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i).getUserName());
		}
		return list;
	}

//	@RequestMapping(value="/add_user",method = RequestMethod.POST)
	@RequestMapping(value="/add_user",method = RequestMethod.GET)
	@ResponseBody
	public User AddUser() {
		User user = new User();
		user.setAge("25");
		user.setId("2");
		user.setUserName("xiaocai");
		userManager.addUser(user);
		return user;
	}
	
}
